import Taro, {Component} from '@tarojs/taro'
import { View } from '@tarojs/components'
import './index.scss'
import classNames from 'classnames'
import { GoodsOneItem } from '@/components/index'

interface IProps {
  list: any
  className?: string
}

export default class GoodsOneList extends Component<IProps, {}> {
  props: any

  static options = {
    addGlobalClass: true
  }

  render() {
    const { list=[], className }:any = this.props
    const last = list.length - 2
    if (!list.length) {
      return (<View className={classNames('goods-one-list', className)}>{this.props.children}</View>)
    }
    return (<View className={classNames('goods-one-list', className)}>
      {list.map((goods, key) => {
        return (<GoodsOneItem key={goods.id} info={goods} className={classNames(last > key && 'thin-border__b')}/>)
      })}
    </View>)
  }
}
